package creditcard.gui;

import bank.BankFrm;
import framework.BaseManager;
import framework.account.IAccount;
import framework.command.ICommand;
import framework.command.impl.DepositCommand;
import framework.command.impl.WithdrawCommand;


public class JDialog_Withdraw extends javax.swing.JDialog
{
   
    /**
	 * @uml.property  name="parentframe"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
    private View view;
    /**
	 * @uml.property  name="name"
	 */
    private IAccount account;

	public JDialog_Withdraw(View parent, IAccount account)
	{
		super(parent);
		view=parent;
        this.account = account;

		// This code is automatically generated by Visual Cafe when you add
		// components to the visual environment. It instantiates and initializes
		// the components. To modify the code, only use code syntax that matches
		// what Visual Cafe can generate, or Visual Cafe may be unable to back
		// parse your Java file into its visual environment.
		//{{INIT_CONTROLS
		setTitle("Charge Account");
		setModal(true);
		getContentPane().setLayout(null);
		setSize(277,134);
		setVisible(false);
		JLabel1.setText("Name");
		getContentPane().add(JLabel1);
		JLabel1.setForeground(java.awt.Color.black);
		JLabel1.setBounds(12,12,48,24);
		JLabel2.setText("Amount");
		getContentPane().add(JLabel2);
		JLabel2.setForeground(java.awt.Color.black);
		JLabel2.setBounds(12,36,48,24);
		JTextField_NAME.setEditable(false);
		getContentPane().add(JTextField_NAME);
		JTextField_NAME.setBounds(84,12,156,20);
		getContentPane().add(JTextField_AMT);
		JTextField_AMT.setBounds(84,36,156,20);
		JButton_OK.setText("OK");
		JButton_OK.setActionCommand("OK");
		getContentPane().add(JButton_OK);
		JButton_OK.setBounds(48,84,84,24);
		JButton_Calcel.setText("Cancel");
		JButton_Calcel.setActionCommand("Cancel");
		getContentPane().add(JButton_Calcel);
		JButton_Calcel.setBounds(156,84,84,24);
		//}}
	    JTextField_NAME.setText(account.getAccountNo());
	
		//{{REGISTER_LISTENERS
		SymAction lSymAction = new SymAction();
		JButton_OK.addActionListener(lSymAction);
		JButton_Calcel.addActionListener(lSymAction);
		//}}
	}



	//{{DECLARE_CONTROLS
	/**
	 * @uml.property  name="jLabel1"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	javax.swing.JLabel JLabel1 = new javax.swing.JLabel();
	/**
	 * @uml.property  name="jLabel2"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	javax.swing.JLabel JLabel2 = new javax.swing.JLabel();
	/**
	 * @uml.property  name="jTextField_NAME"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	javax.swing.JTextField JTextField_NAME = new javax.swing.JTextField();
	/**
	 * @uml.property  name="jTextField_AMT"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	javax.swing.JTextField JTextField_AMT = new javax.swing.JTextField();
	/**
	 * @uml.property  name="jButton_OK"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	javax.swing.JButton JButton_OK = new javax.swing.JButton();
	/**
	 * @uml.property  name="jButton_Calcel"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	javax.swing.JButton JButton_Calcel = new javax.swing.JButton();
	//}}


	class SymAction implements java.awt.event.ActionListener
	{
		public void actionPerformed(java.awt.event.ActionEvent event)
		{
			Object object = event.getSource();
			if (object == JButton_OK)
				JButtonOK_actionPerformed(event);
			else if (object == JButton_Calcel)
				JButtonCalcel_actionPerformed(event);
		}
	}

	void JButtonOK_actionPerformed(java.awt.event.ActionEvent event)
	{
        ICommand command = new WithdrawCommand(account, Float.valueOf(JTextField_AMT.getText()));
        BaseManager.getInstance().execute(command);
		dispose();
	}

	void JButtonCalcel_actionPerformed(java.awt.event.ActionEvent event)
	{
		dispose();
	}
}